package com.dailyblue.java.thread;

import java.util.Date;

public class DemoD1 {

    private Integer i;
    private Object obj = new Object();

    public DemoD1() {
        i = 1;
    }

    public void change() {
        System.out.println("-----------------------------------------------------------------\n\n");
        synchronized (obj) {
            System.out.println(Thread.currentThread().getName() + "准备对i进行操作，目前i的值是：" + i);
            this.i++;
            System.out.println(Thread.currentThread().getName() + "执行完毕，目前i的值是：" + i);
        }

    }

    @Override
    public String toString() {
        return "i:" + i;
    }
}
